import { HOME_URL, ROUTER_WHITE_LIST } from "@/config/constant";
import { GlobalStore } from "@/store";
import router from "./routes";
import { ElMessage } from "element-plus";
console.log("xxxxxxxxx");


router.beforeEach((to, from, next) => {
  const globalStore = GlobalStore();
  
  // 设置标题
  const title = import.meta.env.VITE_GLOB_APP_TITLE;
  document.title = to.meta.title ? `${to.meta.title}` : title;
  if (to.query.id !== to.meta.id) {
    ElMessage.error("游戏id错误");
    setTimeout(() => {
      window.location.href =location.origin+ "/home";
    }, 1000);
  }
  
  //  // 5.判断是否有 Token，没有重定向到 首页 页面
  // if (!globalStore.token && from.path=="/home") return next({ path: HOME_URL, replace: true });

  next(true);
});

export default router;